'use strict'

function validStockCodeA (code) {
  var regex = /^(((30)|(00))\d{4}\.SZ)|(60\d{4}\.SH)$/
  return regex.test(code)
}

function validPageIndex (page_index) {
  var regex = /^[1-9]\d*|0$/
  return regex.test(page_index)
}

function validPageSize (page_size) {
  var regex = /^[1-9]\d*$/
  return regex.test(page_size)
}

function isDateString (dateString) {
  var regex = /^([0-9]{4})-([0-9]{2})-([0-9]{2})$/
  if (regex.test(dateString)) {
    var dt = Date.parse(dateString)
    return !isNaN(dt)
  } else {
    return false
  }
}

module.exports = {
  isValidStockCodeA: validStockCodeA,
  isValidPageIndex: validPageIndex,
  isValidPageSize: validPageSize,
  isValidDateString: isDateString
}